#define _CRT_SECURE_NO_WARNINGS   1

#include<iostream>
using namespace std;

int c, big, little,k, L, n;

int main()
{
	cin >> c;
	while (c--&&(cin>>L>>n))
	{
		big = little = 0;
		for (int i = 0; i < n; i++)
		{
			cin >> k;
			if (k>big)
				big = k;
			if (L - k > big)
				big = L - k;
			if (k > L - k)
				k = L - k;
			if (k > little)
				little = k;
		}
		cout << little << "  " << big;
	}
	if (c == -1)
		cout << endl << "missing input" << endl;
}